package com.zhenti.z1;

import java.util.Arrays;

// 来自微软
// 给定一个正数num，要返回一个大于num的数，并且每一位和相邻位的数字不能相等
// 返回达标的数字中，最小的那个
// 10^9
public class zhenti_P7 {
    public static void main(String[] args) {

        System.out.println(1010 /100);
        System.out.println(Integer.toString(100).length());
        System.out.println(solution(110));
    }
    public static int year(int num){
        char[] raw = ("0" + String.valueOf(num +1)).toCharArray();
        process(raw);
        return Integer.valueOf(String.valueOf(raw));
    }

    private static void process(char[] raw) {
        for (int i = 1; i < raw.length; i++) {
            if (raw[i-1] == raw[i]){
                addOne(raw,i);
                for (int j = i+1; j < raw.length; j++) {
                    raw[j] = '0';
                }
                process(raw);
                return;
            }
        }
    }

    private static void addOne(char[] raw, int i) {
        boolean up = true;
        while (up && raw[i] =='9'){
            raw[i--] = '0';
        }
        raw[i]++;
    }


    public  static int  solution(int num){
        num = num + 1;
        double l = Integer.toString(num).length();

        double i = 0;
        while(i< l) {
            double a =num /Math.pow(10L,l-1);
            int a2 = (int)a;
            double b = num/Math.pow(10L,l-2)-10 * num /Math.pow(10L,l-1 );
           if (a == b ){
               return 2;
           }

        }

        return 1;
    }
}
